import QtQuick 2.8
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import "StackPages/"
Window {
    id: window
    visible: true
    width: 1000
    height: 800
    title: qsTr("Todo")
    RowLayout{
        id:mainLay
        anchors.fill: parent
        spacing:0
        //navigation LeftSidebar
        ListView {
            id: sidebar
            width: 50
            anchors.left: parent.left
            anchors.top: parent.top
            Layout.fillHeight: true
            Layout.minimumWidth: 50
            Layout.preferredWidth: 100
            Layout.maximumWidth: 200

            delegate: Button{
                width: sidebar.width
                height: 50
                property int id: idValue
                property bool statue: false
                flat : statue
                Image {
                        id:btnIco
                        width: 50
                        height: 50
                        source: icoSource
                        fillMode: Image.PreserveAspectFit // For not stretching image (optional)
                        anchors.left: parent.left
                        anchors.top: parent.top
                        anchors.bottom: parent.bottom
                        anchors.margins: 10 // Leaving space between image and borders (optional)
                    }//!=sidebar-ListView-delegate-Image
                    Text {
                        text: content
                        anchors.left: btnIco.right
                        anchors.margins: 5  // Leaving space between text and borders  (optional)
                        anchors.verticalCenter: parent.verticalCenter //这个选项不能和anchors.top/botton同时用，同时用会报错，且用一个选项的话直接没用
                        renderType: Text.NativeRendering // Rendering type (optional)
                    }//!=sidebar-ListView-delegate-Text
                    onClicked: {
                        console.log(index)
                        statue = (statue == false?true:false)
                        for(i=0;i<listModel.count;i++){
                            if(currentIndex = i)
                            listModel.setProperty()
                        }
                    }
            }//!=sidebar-ListView-delegate
            model: ListModel {
                id: listModel
                ListElement { content: "收集"; icoSource: "qrc:/Pic/triangle.png";idValue:1 ;statue:false }
                ListElement { content: "事件"; icoSource: "qrc:/Pic/triangle.png";idValue:2 ;statue:false }
                ListElement { content: "推测"; icoSource: "qrc:/Pic/triangle.png";idValue:3 ;statue:false }
                ListElement { content: "资源"; icoSource: "qrc:/Pic/triangle.png";idValue:4 ;statue:false }
                ListElement { content: "恢复"; icoSource: "qrc:/Pic/triangle.png";idValue:5 ;statue:false }
            }
        }//!=sidebar-ListView
        Item{
            id:showPanel
            Layout.fillHeight: true
            Layout.fillWidth: true
            StackView{
                id: stack
                initialItem: projectCom
                anchors.fill: parent
            }
            Component {
            id: projectCom
                ProjectPanel {
                    id: projectPanel
                    anchors.fill: parent
                }
            }//!=projectCom-Component
            Component {
            id: inboxCom
                Inbox {
                    id: inboxPanel
                    anchors.fill: parent
                }
            }//!=inboxCom-Component
        }//!=showPanel-Item
    }//!=mainLay-RowLayout
}
